{% extends "base.html" %}
{% from "bootstrap/pagination.html" import render_pagination %}

{% block page_content %}
    <div class="page-header">
        <img class="img-rounded profile-avatar" src="{{ user.gravatar(size=220) }}">
        <div class="profile-header">
            <h1>{{ user.username }}</h1>
            <p>性别: {{ user.sex }}</p>
            {% if user.location %}
                <p>地区: {{ user.location }}</p>
            {% endif %}
            {% if user.about_me %}<p>{{ user.about_me }}</p>{% endif %}
                <p>账户注册时间 {{ user.member_since.strftime('%Y-%m-%d %H:%M:%S') }}</p>
                <p>上次登录时间 {{ user.last_seen.strftime('%Y-%m-%d %H:%M:%S') }}</p>
            {% if current_user.is_administrator %}
            <a class="btn btn-danger" href="{{ url_for('.edit_profile_admin', id=user.id) }}">编辑资料</a>
            {% elif user == current_user %}
                <a class="btn btn-primary" href="{{ url_for('.edit_profile') }}">编辑资料</a>
            {% endif %}
            {% if current_user.can(Permission.FOLLOW) and user != current_user %}
                {% if not current_user.is_following(user) %}
                    <a href="{{ url_for('.follow', username=user.username) }}" class="btn btn-primary">关注</a>
                {% else %}
                    <a href="{{ url_for('.unfollow', username=user.username) }}" class="btn btn-default">取消关注</a>
                {% endif %}
            {% endif %}
            <a href="{{ url_for('.followers', username=user.username) }}">
                粉丝: <span class="badge">{{ user.followers.count() - 1 }}</span>
            </a>
            <a href="{{ url_for('.followed_by', username=user.username) }}">
                关注: <span class="badge">{{ user.followed.count() - 1 }}</span>
            </a>
        {% if current_user.is_authenticated and user != current_user and user.is_following(current_user) %}
            | <span class="label label-default">已关注</span>
        {% endif %}
        </div>
    </div>
    <h3>微博：{{ user.username }}</h3>
    {% include "_posts.html" %}
    <div class="pagination">
        {{ render_pagination(pagination, '.index', username=user.username) }}
    </div>
{% endblock %}
